/*
装饰模式：装饰类对实现接口的抽象类（区别于代理模式，非接口的实现类）提供间接访问
*/

//接口类
class Shape{
public:
    virtual void draw() = 0;
    virtual ~Shape() {}
};

//接口的实现类
class Rectangle : public Shape{
public:
    void draw(){
        printf("Draw a rectangle.\n");
    }
};

class Cycle : public Shape{
public:
    void draw(){
        printf("Draw a cycle.\n");
    }
};


//接口的抽象装饰类
class Shape_Decorator: public Shape{
protected:
    Shape* pShape;

public:
    Shape_Decorator(Shape* pshape) : pShape(pshape) {}

    void draw(){
        pShape->draw();
    }
};


//装饰类： 用以调用接口的抽象装饰类
class RedShapeDecorator : public Shape_Decorator{
public:
    RedShapeDecorator(Shape* pshape) : Shape_Decorator(pshape) {}

    void draw(){
        pShape->draw();
        setRedColor();
    }

    void setRedColor(){
        printf("and set red color for it.\n");
    }

};
